﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using GomMinhLongBL;
using GomMinhLongDO;

namespace GomMinhLong
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = Ultility.PageTitle();
            HtmlMeta metaDesc = new HtmlMeta();
            metaDesc.Name = "description";
            metaDesc.Content = new sysConfigBL().Select(new sysConfigDO { ConfigID = 14 }).ConfigValue;
            Page.Header.Controls.Add(metaDesc);

            this.LoadData();
        }

        public void LoadData()
        {
            DataTable dtNews = new DataTable("dtNews");
            dtNews = new cmsArticleBL().SelectGetByParent();
            if ((dtNews != null) && (dtNews.Rows.Count > 0))
            {
                lblDecription.Text = WordCut(dtNews.Rows[0]["Description"].ToString());
                lblDate.Text = dtNews.Rows[0]["CreateDate"].ToString();
                hplImage.ImageUrl = "/Media/" + dtNews.Rows[0]["ImageUrl"].ToString();
                hplImage.NavigateUrl = "/Chi-Tiet-Tin-Tuc/" + dtNews.Rows[0]["ArticleID"].ToString() + "/" + FriendlyUrl(dtNews.Rows[0]["Title"].ToString());
                hplImage.ToolTip = dtNews.Rows[0]["Title"].ToString();
                hplTitle.NavigateUrl = "/Chi-Tiet-Tin-Tuc/" + dtNews.Rows[0]["ArticleID"].ToString() + "/" + FriendlyUrl(dtNews.Rows[0]["Title"].ToString());
                hplTitle.ToolTip = dtNews.Rows[0]["Title"].ToString();
                hplTitle.Text = dtNews.Rows[0]["Title"].ToString();
                hplDetail.NavigateUrl = "/Chi-Tiet-Tin-Tuc/" + dtNews.Rows[0]["ArticleID"].ToString() + "/" + FriendlyUrl(dtNews.Rows[0]["Title"].ToString());

            }
        }

        public string WordCut(string text)
        {
            return Ultility.WordCut(text, 100, new char[] { ' ', '.', ',', ';' }) + "...";

        }

        protected string FriendlyUrl(string strTitle)
        {
            return Ultility.Change_AV(strTitle);
        }
    }
}
